<template>
	<view class="container preferential">


		<image src="/static/img/2/2-7.png" class="over-view"></image>
		
		<view class="carousel-section">
			<!-- 标题栏和状态栏占位符 -->
			<view class="titleNview-placing"></view>
			<!-- 背景色区域 -->
			<view class="titleNview-background" :style="{backgroundColor:titleNViewBackground}"></view>
			<swiper class="carousel" circular @change="swiperChange" indicator-dots=true indicator-active-color=#fff>
				<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item">
					<image :src="item.src" mode="aspectFill" />
				</swiper-item>
			</swiper>


		</view>
		
	
		<view class="goodslist">
			<view class="list-item">
				<image src="/static/img/1/78.png" mode="aspectFill"></image>
				<view class="list-info left">
					<text class="name">新鲜泰国芒果</text>
					<text class="desc">益胃止呕，解渴利尿</text>
					<text class="price">￥50.00</text>
				</view>
			</view>
			<view class="list-item">
				<view class="list-info right">
					<text class="name">新鲜泰国芒果</text>
					<text class="desc">益胃止呕，解渴利尿</text>
					<text class="price">￥50.00</text>
				</view>
				<image src="/static/img/1/78.png" mode="aspectFill"></image>
				
			</view>
		</view>

		<scroll-view scroll-y="true" >
			<view class="guess-section">
				<view 
					v-for="(item, index) in goodsList" :key="index"
					class="guess-item"
					@click="navToDetailPage(item)"
				>
					<view class="image-wrapper">
						<image :src="item.image" mode="aspectFill"></image>
					</view>
						<text class="title clamp">{{item.title}}</text>
						<text class="price"><text class="unit">￥</text>{{item.price}} <text class="pay">125人已付款</text>
							<image class="collect" src="/static/img/2/2-13.png" mode="aspectFill"></image>
							
						</text>
					
					
				</view>
			</view>
			
		</scroll-view>
		<!-- 分享 -->
		<share 
			ref="share" 
			:contentHeight="900"
			:shareList="shareList"
		></share>
	</view>
</template>

<script>
	import share from '@/components/share';
	export default {
		components: {
			share
		},
		data() {
			return {
				titleNViewBackground: 'none',
				swiperCurrent: 0,
				swiperLength: 3,
				shareList: [],
				carouselList: [{
						src: "/static/img/1/105.png",
						background: "none",
					},
					{
						src: "/static/img/1/105.png",
						background: "none",
					},
					{
						src: "/static/img/1/105.png",
						background: "none",
					},
				],
				goodsList: [{
						image: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553187020783&di=bac9dd78b36fd984502d404d231011c0&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201609%2F26%2F20160926173213_s5adi.jpeg",
						image2: "http://pic.rmb.bdstatic.com/819a044daa66718c2c40a48c1ba971e6.jpeg",
						image3: "http://img001.hc360.cn/y5/M00/1B/45/wKhQUVYFE0uEZ7zVAAAAAMj3H1w418.jpg",
						title: "古黛妃 短袖t恤女夏装2019新款韩版宽松",
						price: 179,
						sales: 61,
					},
					{
						image: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=4031878334,2682695508&fm=11&gp=0.jpg",
						image2: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1554013048&di=a3dc9fd1406dd7bad7fbb97b5489ec04&imgtype=jpg&er=1&src=http%3A%2F%2Fimg009.hc360.cn%2Fhb%2FnKo44ac2656F831c684507E3Da0E3a26841.jpg",
						image3: "http://img.zcool.cn/community/017a4e58b4eab6a801219c77084373.jpg",
						title: "潘歌针织连衣裙",
						price: 78,
						sales: 16,
					},
					{
						image: "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1620020012,789258862&fm=26&gp=0.jpg",
						image2: "http://m.360buyimg.com/n12/jfs/t247/42/1078640382/162559/3628a0b/53f5ad09N0dd79894.jpg%21q70.jpg",
						image3: "http://ikids.61kids.com.cn/upload/2018-12-29/1546070626796114.jpg",
						title: "巧谷2019春夏季新品新款女装",
						price: 108.8,
						sales: 5,
					}, {
						image: "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=756705744,3505936868&fm=11&gp=0.jpg",
						image2: "http://images.jaadee.com/images/201702/goods_img/30150_d85aed83521.jpg",
						image3: "http://img13.360buyimg.com/popWaterMark/jfs/t865/120/206320620/138889/dcc94caa/550acedcN613e2a9d.jpg",
						title: "私萱连衣裙",
						price: 265,
						sales: 88,
					}, {
						image: "https://img13.360buyimg.com/n8/jfs/t1/30343/20/1029/481370/5c449438Ecb46a15b/2b2adccb6dc742fd.jpg",
						image2: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553418265666&di=d4a7f7eb0ae3c859edeb921641ee1c3a&imgtype=0&src=http%3A%2F%2Fimg003.hc360.cn%2Fy3%2FM02%2FF8%2F9F%2FwKhQh1TuSkGELIlQAAAAAPuLl4M987.jpg",
						image3: "http://img.ef43.com.cn/product/2016/8/05100204b0c.jpg",
						title: "娇诗茹 ulzzang原宿风学生潮韩版春夏短",
						price: 422,
						sales: 137,
					}, {
						image: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553187020783&di=bac9dd78b36fd984502d404d231011c0&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201609%2F26%2F20160926173213_s5adi.jpeg",
						image2: "http://image5.suning.cn/uimg/b2c/newcatentries/0070158827-000000000622091973_2_800x800.jpg",
						image3: "http://img.61ef.cn/news/201903/20/2019032009251784.jpg",
						title: "古黛妃 短袖t恤女夏装2019新款韩版宽松",
						price: 179,
						sales: 95,
					},
					]
				
				
			};
		},

		async onLoad(options) {
			// this.loadData();
			this.shareList = await this.$api.json('shareList');
		},

		methods: {
			//轮播图切换修改背景色
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;
				this.titleNViewBackground = this.carouselList[index].background;
			},
			
			//详情页
			navToDetailPage(item) {
				//测试数据没有写id，用title代替
				let id = item.title;
				uni.navigateTo({
					url: `/pages/detail/index?id=${id}`
				})
			}
			
		},
	
		onNavigationBarButtonTap(e) {
			// console.log(e)
			
			this.$refs.share.toggleMask();
		
				
		}

	}
</script>

<style lang="scss">
	
	
	page {
		position: relative;
		background: #f5f5f5;
		top: -88upx;
	}



	.m-t {
		margin-top: 16upx;
	}

	.over-view {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 240upx;
		// filter: blur(3upx);
	}
	scroll-view{
		
		.guess-section{
			display:flex;
			flex-wrap:wrap;
			padding: 0 30upx;
			
			.guess-item{
				display:flex;
				flex-direction: column;
				width: 48%;
				padding-bottom: 29upx;
				background: #fff;
				margin-bottom: 21upx;
			
				&:nth-child(2n+1){
					margin-right: 4%;
				}
				
			}
			.image-wrapper{
				width: 100%;
				height: 330upx;
				border-radius: 3px;
				overflow: hidden;
				background: #fff;
				image{
					width: 100%;
					height: 100%;
					opacity: 1;
				}
			}
			.title{
				font-size:23upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(68,68,68,1);
				line-height: 35upx;
				padding-left: 30upx;
				padding-right: 30upx;
			}
			.price{
				font-size:26upx;
				font-family:Adobe Heiti Std;
				font-weight:normal;
				color:rgba(240,64,111,1);
				padding-left: 30upx;
				position: relative;
				.pay{
					font-size:17upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(153,153,153,1);
				}
				.collect{
					position: absolute;
					right: 29upx;
					bottom: 10upx;
					width:30upx;
					height:28upx;
					z-index: 1;
				}
			
			}
			
			
		}
	}
	
	/*商品列表*/
	.goodslist{
		padding: 0 26upx;
		.list-item{
			background: #fff;
			padding: 26upx 0;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-bottom: 31upx;
			border-radius:16upx;
			image{
				width:370upx;
				height:289upx;
			
			}
			.list-info{
				padding: 0 30upx;
				
				.name{
					display: block;
					font-size:40upx;
					font-family:CTBiaoSongSJ;
					font-weight:400;
					color:rgba(255,66,102,1);
					
				}
				.desc{
					display: block;
					font-size:25upx;
					font-family:CTBiaoSongSJ;
					font-weight:400;
					color:rgba(0,0,0,1);
					
				}
				.price{
					width:163upx;
					height:45upx;
					background:rgba(255,47,87,1);
					border-radius:22upx;
					font-size:25upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(255,255,255,1);
					display: flex;
					justify-content: center;
					align-items: center;
					margin-top: 33upx;
				}
				
			}
			.left{
				image{
					
				}
			}
		}
	}
	/* 头部 轮播图 */
	.carousel-section {
		position: relative;
		padding-top: 10px;
		top: 88upx;
		.titleNview-placing {
			height: var(--status-bar-height);
			// padding-top: 377upx;
			box-sizing: content-box;
		}


		.titleNview-background {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 300upx;
			transition: .4s;
		}
	}

	.carousel {
		width: 100%;
		height: 340upx;
		
		

		.carousel-item {
			width: 100%;
			height: 100%;
			padding: 0 26upx;
			overflow: hidden;
		}

		image {
			width: 100%;
			height: 100%;
			border-radius: 10upx;
		}
	}

	.swiper-dots {
		display: flex;
		position: absolute;
		left: 60upx;
		bottom: 15upx;
		width: 72upx;
		height: 36upx;
		background-image: url();
		background-size: 100% 100%;

		.num {
			width: 36upx;
			height: 36upx;
			border-radius: 50px;
			font-size: 24upx;
			color: #fff;
			text-align: center;
			line-height: 36upx;
		}

		.sign {
			position: absolute;
			top: 0;
			left: 50%;
			line-height: 36upx;
			font-size: 12upx;
			color: #fff;
			transform: translateX(-50%);
		}
	}




</style>
